import { useUserStore } from '@/store/user'
import { useCommonStore } from '@/store/common'
import { Router } from 'vue-router'
import { PageEnum } from './permission'

export function setupStateGuard (router: Router) {
  router.afterEach((to) => {
    if (to.name === PageEnum.BASE_LOGIN) {
      const userStore = useUserStore()
      const commonStore = useCommonStore()
      userStore.$reset()
      commonStore.$reset()
    }
  })
}
